package com.itheima;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.itheima.pojo.User;
import com.itheima.service.UserService;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

@SpringBootTest(classes = MpApplication.class)
public class MPTest3 {

    @Autowired
    private UserService userService;

    @Test
    public void testAddUser() {
        User user = User.builder()
                .age(18)
                .userName("liqin")
                //.password("123123")
                .email("liqin@163.com")
                .name("liQin").build();
        boolean isSuccess = userService.save(user);
        System.out.println("isSuccess = " + isSuccess);
    }

    @Test
    public void testSelect() {
        //查包含 伤
        QueryWrapper<User> queryWrapper = new QueryWrapper<User>()
                .orderByAsc("age")
                .orderByDesc("id")
                .select("user_name", "name", "age");

        //userMapper.selectList(queryWrapper).forEach(System.out::println);
        userService.list(queryWrapper).forEach(System.out::println);


    }
}
